<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FDUI</title>
<!-- css -->
<link id="fd_theme" href="../styles/theme/aristo/theme.css" rel="stylesheet" type="text/css" />
<link href="../styles/primeui-1.1-min.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body{font-size: 12px;background-color: white;}
</style>
<!-- lib -->
<script type="text/javascript" src="../src/FDLib/FDLib.js"></script>
<script type="text/javascript" src="../src/JsMap.js"></script>
<script type="text/javascript" src="treeData.js"></script>
</head>
<body>
<div style="padding:5px;">
	<a href="javascript:tree.expandAll()">全部展开</a> <a href="javascript:tree.collapseAll();">全部收缩</a>
</div>
<div style="padding: 5px;border: 1px solid #ccc;">
主题(<span id="themeCnt"></span>种):<div id="themeRadio"></div>
</div>
<div id="menu"></div>

<script type="text/javascript">
//设置路径
FDLib.setDir('../src/');
var tree;
var themeSel;
//主题
var themes = ['afterdark','afternoon','afterwork','aristo','black-tie','blitzer','bluesky','bootstrap','casablanca','cruze','cupertino','dark-hive','delta','dot-luv','eggplant','excite-bike','flick','glass-x','home','hot-sneaks','humanity','le-frog','midnight','mint-choc','overcast','pepper-grinder','redmond','rocket','sam','smoothness','south-street','start','sunny','swanky-purse','trontastic','ui-darkness','ui-lightness','vader']

FDLib.loadJs(['FDTree','FDTree','FDSelectBox'],function() {
	var mainUrl;
	tree = new FDTree({
		domId:'menu'
		,data:treeData
		,clickToggle:true
		,highlightHandler:function(node){
			if(node.url){
				return true;
			}
			if(node.children && node.children.length > 0){
				return false;
			}
			return true;
		}
		,onclick:function(node) {
			if(node.url) {
				mainUrl = node.url;
				var themeName = themeSel.getValue();
				parent.mainFrame.location.href = mainUrl + '?theme=' + themeName + '&srId=1';
			}
		}
	});
	
	tree.expandAll();
	
	// 主题切换
	FDLib.getEl('themeCnt').innerHTML = themes.length;
	var items = [];
	for(var i=0,len=themes.length;i<len;i++){
		var themeName = themes[i];
		items.push({text:themeName,value:themeName});
	}
	themeSel = new FDSelectBox({domId:'themeRadio'
		,name:"theme"
		,items:items
		,defaultValue:'aristo'
		,showDefault:false});
	
	themeSel.addEvent('change',function(){
		var themeName = this.value;
		var themeLink = FDLib.getEl('fd_theme');
		themeLink.href = '../styles/theme/'+themeName+'/theme.css';
		
		reloadMainPage(mainUrl, themeName);
	});
	
	tree.select('aboveAll');
});


function reloadMainPage(url,themeName){
	if(url){
		parent.mainFrame.location.href = url + '?theme=' + themeName;
	}
}
</script>
</body>
</html>